package com.bj58.mis.apm.server.statistics.dto.cube;

import com.bj58.mis.apm.server.statistics.dto.DtoUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.sql.Timestamp;

/**
 * @author: zhangfx
 * @create: 2018-06-19 17:25
 **/
@ApiModel(description = "Cube信息")
@Data
public class CubeInfo {
    @ApiModelProperty(value = "cube id")
    private String id;

    @ApiModelProperty(value = "项目标识")
    private String projectCode;
    @ApiModelProperty(value = "项目名称")
    private String projectName;

    @ApiModelProperty(value = "负责人，负责人OA账号，逗号分割")
    private String owners;

    @ApiModelProperty(value = "创建人")
    private String creater;

    @ApiModelProperty(value = "修改人")
    private String mender;

    @ApiModelProperty(value = "Cube描述")
    private String description;

    @ApiModelProperty(value = "更新周期")
    private String cycle;



    //英文名称
    private String nameEn;

    @ApiModelProperty(value = "Cube名称")
    private String name;

    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @ApiModelProperty(value = "cuboids")
    private int cuboids;

    @ApiModelProperty(value = "状态")
    private String status;

    @ApiModelProperty(value = "大小，单位byte")
    private long dataSize;

    @ApiModelProperty(value = "膨胀倍数")
    private double swell;

    @ApiModelProperty(value = "查询次数")
    private long queryCount;

    @ApiModelProperty(value = "慢查询数")
    private long slowQueryCount;

    @ApiModelProperty(value = "最后修改时间")
    private Timestamp lastModified;

    @ApiModelProperty(value = "最后构建时间")
    private Timestamp lastBuildedTime;

    @ApiModelProperty(value = "最后查询时间")
    private Timestamp lastQueryTime;

    @ApiModelProperty(value = "Cube标示")
    public String getCode(){
        return DtoUtil.getCubeCode(nameEn);
    }
    @ApiModelProperty(value = "Cube版本号")
    public String getVersion(){
        if(nameEn!=null){
            int idx = nameEn.lastIndexOf("_");
            if(idx>0){
                return nameEn.substring(idx+1);
            }
        }
        return null;
    }

}
